<div class="upload">
    <h3><?php echo $title; ?></h3>
    <h4><?php echo $ReviewData; ?></h4>
    
        <?php 
        if (isset($data) && !empty($data)): ?>
            <table border="1" width="100%">
                <tr id="th">
                    <th><?php echo $this->lang->line('LR_Order'); ?></th>
                    <?php foreach ($data as $ar){$count = count($ar);break;} ?>
                    <?php for($b=0;$b<$count;$b++){?>
                        <th><?php echo $this->lang->line('tcmanipulation_Colum'); ?> <?php echo $b+1; ?></th>
                    <?php } ?>
                </tr>
                <?php $i = 1;
                foreach ($data as $ar){ ?>
                    <tr>
                        <td><?php echo $i++; ?></td>
                        <td><?php if(isset($ar[0])){echo $ar[0];}else{echo '';} ?></td>
                        <td><?php if(isset($ar[1])){echo $ar[1];}else{echo '';} ?></td>
                        <td><?php if(isset($ar[2])){echo $ar[2];}else{echo '';} ?></td>
                        <td><?php if(isset($ar[3])){echo $ar[3];}else{echo '';} ?></td>
                        <td><?php if(isset($ar[4])){echo $ar[4];}else{echo '';} ?></td>
                        <td><?php if(isset($ar[5])){echo $ar[5];}else{echo '';} ?></td>
                    </tr>
            <?php  if ($i == 5) {break;}
                }
            ?>
            </table>
    
    <h4><?php echo $SelectData; ?></h4>
            <form name="frmsavedata" id="frmsavedata" method="POST" action="<?php echo base_url();?>time-card-manipulation/import">       
            <table border="1" width="100%">
                <tr id="th">
                    <th width="25%"><?php echo $this->lang->line('tcmanipulation_EmployeeID');?></th>
                    <th width="25%"><?php echo $this->lang->line('tcmanipulation_Date');?></th>
                    <th width="25%"><?php echo $this->lang->line('tcmanipulation_ActualArrivalTime');?></th>
                    <th width="25%"><?php echo $this->lang->line('tcmanipulation_ActualLeaveTime');?></th>
                </tr>
                <tr>
                    <td>
                        <select name="cboEmployeeID">
                            <?php for($b=0;$b<$count;$b++):
                            if($b==1){
                                ?>
                                <option value="<?php echo $b; ?>" selected="selected"><?php echo $this->lang->line('tcmanipulation_Colum'); ?><?php echo $b+1; ?> </option>
                                <?php
                            }
                            else{
                               ?>
                                <option value="<?php echo $b; ?>"><?php echo $this->lang->line('tcmanipulation_Colum'); ?><?php echo $b+1; ?></option>  
                                <?php
                            }
                            ?>
                            <?php endfor;?>
                        </select>
                    </td>
                    <td>
                        <select name="cboDate">
                            <?php for($b=0;$b<$count;$b++):
                            if($b==3){
                                ?>
                                <option value="<?php echo $b; ?>" selected="selected"><?php echo $this->lang->line('tcmanipulation_Colum'); ?><?php echo $b+1; ?> </option>
                                <?php
                            }
                            else{
                               ?>
                                <option value="<?php echo $b; ?>"><?php echo $this->lang->line('tcmanipulation_Colum'); ?><?php echo $b+1; ?></option>  
                                <?php
                            }
                            ?>
                            <?php endfor;?>
                        </select>
                    </td>
                    <td>
                        <select name="cboArrivaltime">
                            <?php for($b=0;$b<$count;$b++):
                            if($b==4){
                                ?>
                                <option value="<?php echo $b; ?>" selected="selected"><?php echo $this->lang->line('tcmanipulation_Colum'); ?><?php echo $b+1; ?> </option>
                                <?php
                            }
                            else{
                               ?>
                                <option value="<?php echo $b; ?>"><?php echo $this->lang->line('tcmanipulation_Colum'); ?><?php echo $b+1; ?></option>  
                                <?php
                            }
                            ?>
                            <?php endfor;?>
                        </select>
                    </td>
                    <td>
                        <select name="cboLeavetime">
                            <?php for($b=0;$b<$count;$b++):
                            if($b==5){
                                ?>
                                <option value="<?php echo $b; ?>" selected="selected"><?php echo $this->lang->line('tcmanipulation_Colum'); ?><?php echo $b+1; ?> </option>
                                <?php
                            }
                            else{
                               ?>
                                <option value="<?php echo $b; ?>"><?php echo $this->lang->line('tcmanipulation_Colum'); ?><?php echo $b+1; ?></option>  
                                <?php
                            }
                            ?>
                            <?php endfor;?>
                        </select>
                    </td>
                </tr>
            </table>
            <input type="submit" value="<?php echo $this->lang->line('tcmanipulation_import'); ?>" name="btnSubmit" id="btnImport" />
            </form>
<?php endif;?>
</div>
<!-- BEGIN dialog message -->
<div id="dialog" title="<?php echo $this->lang->line('CR_dialog_title'); ?>">
    <?php echo isset($message) ? $message : ''; ?>
</div>
<!-- END dialog message -->
<script type="text/javascript">
    $(document).ready(function() {
<?php if (isset($flag) && $flag == TRUE): ?>
            $(function() {
                $("#dialog").dialog({
                    modal: true,
                    close: function() {
                        window.location.href = '<?php echo base_url('/listtimecard'); ?>';
                    },
                    buttons: [{
                        text: "<?php echo $this->lang->line('MC019');?>",
                        click: function() {
                            window.location.href = '<?php echo base_url('/listtimecard'); ?>';
                        },
                    }]
                });
            });
<?php elseif (isset($flag) && $flag == FALSE): 
    if(isset($url)&&$url!=''){
?>
            $(function() {
                $("#dialog").dialog({
                    modal: true,
                    close: function() {
                        window.location.href = '<?php echo base_url().$url; ?>';
                    },
                    buttons: [{
                        text: "<?php echo $this->lang->line('MC019');?>",
                        click: function() {
                            window.location.href = '<?php echo base_url().$url; ?>';
                        },
                    }]
                });
            });
    <?php }
          else{
    ?>
            $(function() {
                $("#dialog").dialog({
                    modal: true,
                    close: function() {
                        $( this ).dialog( "close" );
                    },
                    buttons: [{
                        text: "<?php echo $this->lang->line('MC019');?>",
                        click: function() {
                            $( this ).dialog( "close" );
                        },
                    }]
                });
            });            
    <?php
          }
    endif; 
    ?>
    });
</script>